package org.trendit

class User {
	String userId
    String password
	String homepage
	Date dateCreated
	Profile profile
    static constraints = {
		userId(size:3..20, unique: true)
		password(size: 6..8,
			 validator: { passwd, user ->
				  return passwd != user.userId
		})
		homepage(url: true, nullable: true)
		profile(nullable: true)
    }
	static mapping = { 
		profile lazy:false
	}
	static hasMany = [ posts : Post, tags : Tag, following : User ]
	String toString() {
		"User with id= ${userId} (${id})"
		}
}
